<?php include("header.inc.php") ?>
<?php include("navigation.inc.php")?>       
<?php include("left.inc.php")?>     
<!--
<!--
	1 ) Reference to the files containing the JavaScript and CSS.
	These files must be located on your server.
-->

<script type="text/javascript" src="highslide/highslide-with-gallery.js"></script>
<link rel="stylesheet" type="text/css" href="highslide/highslide.css" />

<!--
	2) Optionally override the settings defined at the top
	of the highslide.js file. The parameter hs.graphicsDir is important!
-->

<script type="text/javascript">
	hs.graphicsDir = 'highslide/graphics/';
	hs.align = 'center';
	hs.transitions = ['expand', 'crossfade'];
	hs.wrapperClassName = 'dark borderless floating-caption';
	hs.fadeInOut = true;
	hs.dimmingOpacity = .75;

	// Add the controlbar
	if (hs.addSlideshow) hs.addSlideshow({
		//slideshowGroup: 'group1',
		interval: 5000,
		repeat: false,
		useControls: true,
		fixedControls: 'fit',
		overlayOptions: {
			opacity: .6,
			position: 'center',
			hideOnMouseOut: true
		}
	});
</script>

<!--
	4) This is how you mark up the thumbnail image with an anchor tag around it.
	The anchor's href attribute defines the URL of the full-size image.
-->
    
    
    <!--
        5 (optional). This is how you mark up the caption. The correct class name is important.
    -->

<div id="mainContent" class="grid_7">
  	<div class="grid_7">
    	<img src="img/gallery.PNG" width="585px" height="25" style="margin-top:10px;" />
    </div> 
    <div id="thuvienanh" class="highslide-gallery">
    	<?php 
		$display = 12;
        if (isset($_GET['page']) && (int)$_GET['page']) {
 	           $page = $_GET['page'];	
        } else {                   
    	       $sql = "SELECT COUNT(idhinhanhhoatdong) FROM hinhanhhoatdong WHERE status = 1";
               $query = mysql_query($sql) or die("Error query count ".mysql_error($conn));
               $rows = mysql_fetch_array($query);
               $record = $rows[0];
	           if ($record > $display) {
    	             $page = ceil($record/$display);	
               } else {
                     $page = 1;	
               }                
        $start = (isset($_GET['start']) && (int)$_GET['start'])?$_GET['start']:0;			
		$sql = "SELECT  * FROM hinhanhhoatdong WHERE STATUS = 1 ORDER BY thoigian DESC LIMIT $start,$display ";
		$query = mysql_query($sql) or die("Can't query hinhanhhoatdong");
		while ($row = mysql_fetch_array($query))
		{		
		?>
    		<div class="hinhanh">
        		<a href="img/gallery/<?php echo $row['anhfull']?>" class="highslide" onclick="return hs.expand(this)">
                    <img src="img/gallery/<?php echo $row['anhpreview']?>" alt="<?php echo $row['mota']?>"
                        title="<?php echo $row['tenanh']?>" />
                </a>
       		</div>
            <div class="highslide-caption">
        		<?php echo $row['mota'] ?>
    		</div>
        <?php
		}
		}
		?>
    </div>
    
        <div class="pagelist">
        	 <ul>
        <?php						
					if($page > 1) {
						$next = $start + $display;
						$previous = $start - $display;
						$current = ($start/$display) + 1;				
						if ($current != 1) {
							echo "<li><a href='hinhanh.php?start=$previous'>Quay Lại</a></li>";	
						} 
						for ($i=1;$i<=$page;$i++){
							if($i != $current) {
								echo "<li><a href='hinhanh.php?start=".($display*($i-1))."'>$i</a></li>";	
							} else {
								echo "<li class='current'>$i</li>";		
							}
						}
						if ($current != $page){
							echo "<li><a href='hinhanh.php?start=$next'>Tiếp</a></li>";	
						}
					}
		?>
	         </ul>
    	</div>                              
</div>

<!--
	3) Put the thumbnails inside a div for styling
-->
     
<?php include("right.inc.php")?>  
<?php include("footer.inc.php")?>  

